package com.qzd.springclude.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

import com.qzd.springclude.entity.Dept;

@Controller
public class DeptController {
	//private static final String REST_URL="http://127.0.0.1:8001";
	private static final String REST_URL="http://MICROSERVICECLOUD-DEPT";

	@Autowired
	private RestTemplate resttemplate;
	
	@RequestMapping("dept/findbyid")
	@ResponseBody
	public Dept findByid(Integer id){
		//请求的地址
		//请求参数
		//http响应的转换的对象类型
		//return resttemplate.postForObject("", "", Dept.class);
		//url：请求的地址
		//http响应的转换的对象类型
		return resttemplate.getForObject(REST_URL+"/dept/findbyid?id="+id, Dept.class);
	}
	//测试服务发现
	@RequestMapping("dept/discovery")
	@ResponseBody
	public Object discovery(){
		return resttemplate.getForObject(REST_URL+"/dept/discovery", Object.class);			
	}
	
}
